import 'package:flutter/material.dart';
import 'package:xingsu/page/mine/video_status_page.dart';

class VideoStatusParentPage extends StatefulWidget {
  final int index;

  VideoStatusParentPage(this.index);

  @override
  State<VideoStatusParentPage> createState() => _VideoStatusParentPageState();
}

class _VideoStatusParentPageState extends State<VideoStatusParentPage>
    with
        AutomaticKeepAliveClientMixin<VideoStatusParentPage>,
        TickerProviderStateMixin {
  final _titles = ["全部", "待审核", "已审核", "无效视频"];
  late TabController _controller;

  @override
  void initState() {
    super.initState();

    _controller = TabController(
      length: _titles.length,
      initialIndex: widget.index,
      vsync: this,
    );
  }

  @override
  void dispose() {
    super.dispose();

    _controller.dispose();
  }

  @override
  Widget build(BuildContext context) {
    super.build(context);
    return Scaffold(
      appBar: AppBar(
        title: const Text("视频状态"),
      ),
      body: Column(
        children: [
          TabBar(
              isScrollable: true,
              controller: _controller,
              tabs: _titles
                  .map((e) => Tab(
                        text: e,
                      ))
                  .toList()),
          Expanded(
              child: TabBarView(
            controller: _controller,
            children: [
              VideoStatusPage(
                index: 0,
                key: UniqueKey(),
              ),
              VideoStatusPage(
                index: 1,
                key: UniqueKey(),
              ),
              VideoStatusPage(
                index: 2,
                key: UniqueKey(),
              ),
              VideoStatusPage(
                index: 3,
                key: UniqueKey(),
              )
            ],
          ))
        ],
      ),
    );
  }

  @override
  bool get wantKeepAlive => true;
}
